Release 10.1A: OpenEdge Application Server:
Developing WebSpeed Applications
Handling form input
The following shows the section of
w-sstget.html, which uses embedded SpeedScript to handle input from an HTML form:
This HTML file uses a different set of statement escape tags (
<!--WSS ... -->) than the previous example, but they have the same effect.The first
IF...THENstatement invokes theFINDstatement to read a customer record if a customer number (CustNum) is entered by the user. This user enters a customer number in the Web page initially generated by the Web object, as shown in Figure 2–2.Figure 2–2: User input page generated by w-sstget
![]()
This input is tested by the
get-valuefunction, which is one of the WebSpeed API functions that facilitate IO between Web pages and Web objects. Theget-valuefunction returns the value of a named element passed with a request, including a form element, a query string element, a cookie, or a user field (an internally defined list value). In this case, the function looks for the value of theCustNumform field defined in the HTML.For more information on WebSpeed API functions, see Appendix A "WebSpeed API reference." You can also access the WebSpeed API Reference from the AppBuilder online help. Choose Help
Note: TheHelp Topics from the AppBuilder menu bar. Then select the Find tab and enter WebSpeed API in the top field of the dialog box. Also see the "WebSpeed API functions" section for an overview of some commonly used API functions.
NO-ERRORoption on theFINDstatement allows the Web object to continue execution if theFINDstatement fails because theCustNumvalue is invalid.The HTML for the
CustNumform element (field) also includes an expression escape tag to provide the field value. The expression contains the SpeedScriptIF...THEN...ELSEfunction, which returns a value based on a condition. Here, the function tests whether the Web object found a customer record by returning the value of the SpeedScriptAVAILABLEfunction on the Customer table (TRUEorFALSE). TheAVAILABLEfunction value is alwaysFALSEfor the initial request and a null string value is returned for theIF...THEN...ELSEfunction.The second
IF...THENstatement also checksAVAILABLE(Customer), and generates HTML to display several Customer field values only if there is a customer record available. This secondIF...THENstatement encloses the relevant HTML in aDOblock terminated by anENDstatement to ensure that all the HTML is generated for the available customer record.Figure 2–3 shows the HTML output as it would appear in a browser.
Figure 2–3: Customer information generated by w-sstget Note: Although expression escape tags output all SpeedScript expressions as character strings, the values that combine to make a SpeedScript expression can have other data types, such as integer. SpeedScript requires compatible data types in expressions. In the example, the SpeedScript
![]()
INTEGERfunction converts the character value of theget-valueAPI function to an integer in order to allow comparison with the integerCustNumfield in the Customer table. Similarly, the SpeedScriptSTRINGfunction converts the integer value ofCustNumto a character string in theIF...THEN...ELSEfunction, because the alternative values for the function must have compatible data types.As these examples show, you can achieve a fine degree of control over HTML generation within an embedded SpeedScript Web object.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |